<template>
    <view id="app" :class="themeClass" :style="themeVars">
        <router-view></router-view>
    </view>
</template>

<script setup lang="ts">
import { useTheme } from '@/composables/useTheme'

// 主题管理
const { currentTheme, getThemeVars, getThemeClass, initTheme } = useTheme()

// 计算主题类名和变量
const themeClass = computed(() => getThemeClass())
const themeVars = computed(() => getThemeVars())

onLaunch(() => {
    // 初始化主题
    initTheme()

    // routingIntercept()
})

onShow(() => {
    console.log('App Show')
})

onHide(() => {
    console.log('App Hide')
})

// 提供全局主题状态
provide('theme', {
    currentTheme,
    themeClass,
    themeVars
})
</script>

<style lang="scss">
/* 注意要写在第一行，同时给style标签加入lang="scss"属性 */
@import 'uview-plus/index.scss';
@import '@/styles/theme.scss';
</style>
